import { Component, ViewChild, Injector, Output, EventEmitter, ViewEncapsulation, ElementRef } from '@angular/core';
import { ModalDirective } from 'ngx-bootstrap';
import { AppComponentBase } from '@shared/app-component-base';
import { AppConsts } from '@shared/AppConsts';
import {
  OrderServiceProxy, OrderDetailForAdminOutDto,
  OrderItemForAdminOutDto, UserAddressOutDto, FullCityOutDto
} from "@shared/service-proxies/service-proxies";

@Component({
  selector: 'app-order-detail',
  templateUrl: './order-detail.component.html',
  styleUrls: ['./order-detail.component.css']
})
export class OrderDetailComponent extends AppComponentBase {
  @ViewChild('orderDetailModal') modal: ModalDirective;

  active: boolean = false;
  orderDetail: OrderDetailForAdminOutDto = null;
  constructor(injector: Injector,
    private _orderService: OrderServiceProxy) {
    super(injector)
  }
  show(id?: number): void {
    this.active = true;
    this.getOrderInfo(id);
    this.modal.show();
  }
  close(): void {
    this.active = false;
    this.modal.hide();
  }
  getOrderInfo(id?: number): void {
    this._orderService.getOrderForAdminAsync(id).subscribe((result: OrderDetailForAdminOutDto) => {
      this.orderDetail = result;
    });
  }
}
